<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>新增或者修改页</title>
    <style>
        body{
            background-color: antiquewhite;
        }
        #d1{
            display: flex;
            justify-content: center;
            align-items: center;
            height: 600px;
        }
        #d2{
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            border: 1px solid;
            height: 220px;
            width: 280px;
            background-color: sandybrown;
            box-shadow: 5px 5px 2.5px #888888 ;
            border-radius: 10px;
        }
        #cc{
            margin-left: 20px;
        }
    </style>

</head>
<body>
    <div id="d1">
        <div id="d2">
            <table>
                <tr hidden>
                    <td><label for="">ID：</label></td>
                    <td><input type="text" name="id"></td>
                </tr>
                <tr>
                    <td><label for="">标题：</label></td>
                    <td><input type="text" name="biaoti"></td>
                </tr>
                <tr>
                    <td><label for="">摘要：</label></td>
                    <td><input type="text" name="zhaiyao"></td>
                </tr>
                <tr>
                    <td><label for="">内容：</label></td>
                    <td><input type="text" name="neirong"></td>
                </tr>
                <tr>
                    <td><label for="">分类：</label></td>
                    <td><input type="text" name="fenlei"></td>
                </tr>
                <tr>
                    <td><label for="">作者：</label></td>
                    <td><input type="text" name="zuozhe"></td>
                </tr>
                <tr>
                    <td><label for=""></label></td>
                    <td>
                        <input type="button" value="保存" onclick="save()">
                        <input type="button" value="取消" onclick="cancel()" id="cc">
                    </td>
                </tr>
            </table>
        </div>
    </div>
    
    <script src="./js/jquery-3.6.0.min.js"></script>
    <script src="./js/product_api.js"></script>
    <script src="./js/init.js"></script>
    <script>
        $(function () {
            let id = location.search.split('?')[1];
            if (id) {
                getProductById(id).then(res => {
                    $('[name=id]').val(res['data'].id)
                    $('[name=biaoti]').val(res['data'].biaoti)
                    $('[name=zhaiyao]').val(res['data'].zhaiyao)
                    $('[name=neirong]').val(res['data'].neirong)
                    $('[name=fenlei]').val(res['data'].zuozhe)
                })
            }
        })
    </script>

</body>
</html>